#include "board.h"
#include<QPainter>

board::board(QWidget *parent) : QWidget(parent)
{

}
void board::paintEvent(QPaintEvent *){
    QPainter painter(this);
    int d=40;//d为棋子直径
    //一共画十条横线
    for(int i=1;i<=10;i++){
        painter.drawLine(QPoint(d,i*d),QPoint(9*d,i*d));
    }
    //一共画九条竖线，但是中间有分界
    for(int i=1;i<=9;i++){
        if(i==9||i==1){
        painter.drawLine(QPoint(i*d,d),QPoint(i*d,10*d));
        }
        else{
            painter.drawLine(QPoint(i*d,d),QPoint(i*d,5*d));
            painter.drawLine(QPoint(i*d,6*d),QPoint(i*d,10*d));
        }
    }
    //画“将”“帅”所在格子
    painter.drawLine(QPoint(4*d,d),QPoint(6*d,3*d));
     painter.drawLine(QPoint(6*d,d),QPoint(4*d,3*d));
    painter.drawLine(QPoint(4*d,8*d),QPoint(6*d,10*d));
     painter.drawLine(QPoint(6*d,8*d),QPoint(4*d,10*d));

}
